package tliasmanagement.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tliasmanagement.mapper.DeptMapper;
import tliasmanagement.pojo.Dept;
import tliasmanagement.service.DeptService;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class DeptServiceImpl implements DeptService {

    @Autowired
    private DeptMapper deptMapper;

    /*
     * 查询所有部门
     * */
    @Override
    public List<Dept> findAll() {
        return deptMapper.findAll();
    }

    /*
     * 删除部门
     * */
    @Override
    public void deleteById(Integer id) {
        deptMapper.deleteById(id);
    }


    /*
     * 添加部门
     * */
    @Override
    public void add(Dept dept) {
        //补全基础属性
        dept.setCreateTime(LocalDateTime.now());
        dept.setUpdateTime(LocalDateTime.now());
        deptMapper.add(dept);
    }

    /*
     * 查询部门
     * */
    @Override
    public Dept findById(Integer id) {
        return deptMapper.findById(id);
    }

    /*
     * 修改部门
     * */
    @Override
    public void update(Dept dept) {
        dept.setUpdateTime(LocalDateTime.now());
        deptMapper.update(dept);
    }
}
